/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidad;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author a
 */
@Entity
@Table(name = "orden")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Orden.findAll", query = "SELECT o FROM Orden o"),
    @NamedQuery(name = "Orden.findByIdOrden", query = "SELECT o FROM Orden o WHERE o.idOrden = :idOrden"),
    @NamedQuery(name = "Orden.findByNoOrden", query = "SELECT o FROM Orden o WHERE o.noOrden = :noOrden"),
    @NamedQuery(name = "Orden.findByFecha", query = "SELECT o FROM Orden o WHERE o.fecha = :fecha"),
    @NamedQuery(name = "Orden.findByTotal", query = "SELECT o FROM Orden o WHERE o.total = :total"),
    @NamedQuery(name = "Orden.findByDescuento", query = "SELECT o FROM Orden o WHERE o.descuento = :descuento"),
    @NamedQuery(name = "Orden.findByGranTotal", query = "SELECT o FROM Orden o WHERE o.granTotal = :granTotal"),
    @NamedQuery(name = "Orden.findByCortesia", query = "SELECT o FROM Orden o WHERE o.cortesia = :cortesia"),
    @NamedQuery(name = "Orden.findByActivo", query = "SELECT o FROM Orden o WHERE o.activo = :activo"),
    @NamedQuery(name = "Orden.findByPagado", query = "SELECT o FROM Orden o WHERE o.pagado = :pagado"),
    @NamedQuery(name = "Orden.findByTotalTarjeta", query = "SELECT o FROM Orden o WHERE o.totalTarjeta = :totalTarjeta"),
    @NamedQuery(name = "Orden.findByTotalEfectivo", query = "SELECT o FROM Orden o WHERE o.totalEfectivo = :totalEfectivo"),
    @NamedQuery(name = "Orden.findByPropinaTarjeta", query = "SELECT o FROM Orden o WHERE o.propinaTarjeta = :propinaTarjeta"),
    @NamedQuery(name = "Orden.findByNoVoucherTarjeta", query = "SELECT o FROM Orden o WHERE o.noVoucherTarjeta = :noVoucherTarjeta"),
    @NamedQuery(name = "Orden.findByMinutosEspera", query = "SELECT o FROM Orden o WHERE o.minutosEspera LIKE :minutosEspera")})
public class Orden implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idOrden")
    private Integer idOrden;
    @Basic(optional = false)
    @Column(name = "noOrden")
    private int noOrden;
    @Basic(optional = false)
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "total")
    private Float total;
    @Column(name = "descuento")
    private Float descuento;
    @Column(name = "granTotal")
    private Float granTotal;
    @Column(name = "cortesia")
    private Boolean cortesia;
    @Column(name = "activo")
    private Boolean activo;
    @Column(name = "pagado")
    private Boolean pagado;
    @Column(name = "totalTarjeta")
    private Float totalTarjeta;
    @Column(name = "totalEfectivo")
    private Float totalEfectivo;
    @Column(name = "propinaTarjeta")
    private Float propinaTarjeta;
    @Column(name = "noVoucherTarjeta")
    private String noVoucherTarjeta;
    @Column(name = "minutosEspera")
    private Integer minutosEspera;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ordenidOrden")
    private Collection<Deuda> deudaCollection;
    @JoinColumn(name = "Usuario_idUsuario", referencedColumnName = "idUsuarios")
    @ManyToOne(optional = false)
    private Usuarios usuarioidUsuario;
    @JoinColumn(name = "Mesa_idMesa", referencedColumnName = "idMesa")
    @ManyToOne(optional = false)
    private Mesa mesaidMesa;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ordenidOrden")
    private Collection<Detalleorden> detalleordenCollection;

    public Orden() {
    }

    public Orden(Integer idOrden) {
        this.idOrden = idOrden;
    }

    public Orden(Integer idOrden, int noOrden, Date fecha) {
        this.idOrden = idOrden;
        this.noOrden = noOrden;
        this.fecha = fecha;
    }

    public Integer getIdOrden() {
        return idOrden;
    }

    public void setIdOrden(Integer idOrden) {
        Integer oldIdOrden = this.idOrden;
        this.idOrden = idOrden;
        changeSupport.firePropertyChange("idOrden", oldIdOrden, idOrden);
    }

    public int getNoOrden() {
        return noOrden;
    }

    public void setNoOrden(int noOrden) {
        int oldNoOrden = this.noOrden;
        this.noOrden = noOrden;
        changeSupport.firePropertyChange("noOrden", oldNoOrden, noOrden);
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        Date oldFecha = this.fecha;
        this.fecha = fecha;
        changeSupport.firePropertyChange("fecha", oldFecha, fecha);
    }

    public Float getTotal() {
        return total;
    }

    public void setTotal(Float total) {
        Float oldTotal = this.total;
        this.total = total;
        changeSupport.firePropertyChange("total", oldTotal, total);
    }

    public Float getDescuento() {
        return descuento;
    }

    public void setDescuento(Float descuento) {
        Float oldDescuento = this.descuento;
        this.descuento = descuento;
        changeSupport.firePropertyChange("descuento", oldDescuento, descuento);
    }

    public Float getGranTotal() {
        return granTotal;
    }

    public void setGranTotal(Float granTotal) {
        Float oldGranTotal = this.granTotal;
        this.granTotal = granTotal;
        changeSupport.firePropertyChange("granTotal", oldGranTotal, granTotal);
    }

    public Boolean getCortesia() {
        return cortesia;
    }

    public void setCortesia(Boolean cortesia) {
        Boolean oldCortesia = this.cortesia;
        this.cortesia = cortesia;
        changeSupport.firePropertyChange("cortesia", oldCortesia, cortesia);
    }

    public Boolean getActivo() {
        return activo;
    }

    public void setActivo(Boolean activo) {
        Boolean oldActivo = this.activo;
        this.activo = activo;
        changeSupport.firePropertyChange("activo", oldActivo, activo);
    }
    
    //si esta pagado sin deuda estara en True
     public Boolean getPagado() {
        return pagado;
    }

    public void setPagado(Boolean pagado) {
        Boolean oldPagado = this.pagado;
        this.pagado = pagado;
        changeSupport.firePropertyChange("pagado", oldPagado, pagado);
    }

    public Float getTotalTarjeta() {
        return totalTarjeta;
    }

    public void setTotalTarjeta(Float totalTarjeta) {
        Float oldTotalTarjeta = this.totalTarjeta;
        this.totalTarjeta = totalTarjeta;
        changeSupport.firePropertyChange("totalTarjeta", oldTotalTarjeta, totalTarjeta);
    }

    public Float getTotalEfectivo() {
        return totalEfectivo;
    }

    public void setTotalEfectivo(Float totalEfectivo) {
        Float oldTotalEfectivo = this.totalEfectivo;
        this.totalEfectivo = totalEfectivo;
        changeSupport.firePropertyChange("totalEfectivo", oldTotalEfectivo, totalEfectivo);
    }

    public Float getPropinaTarjeta() {
        return propinaTarjeta;
    }

    public void setPropinaTarjeta(Float propinaTarjeta) {
        Float oldPropinaTarjeta = this.propinaTarjeta;
        this.propinaTarjeta = propinaTarjeta;
        changeSupport.firePropertyChange("propinaTarjeta", oldPropinaTarjeta, propinaTarjeta);
    }

    public String getNoVoucherTarjeta() {
        return noVoucherTarjeta;
    }

    public void setNoVoucherTarjeta(String noVoucherTarjeta) {
        String oldNoVoucherTarjeta = this.noVoucherTarjeta;
        this.noVoucherTarjeta = noVoucherTarjeta;
        changeSupport.firePropertyChange("noVoucherTarjeta", oldNoVoucherTarjeta, noVoucherTarjeta);
    }

    public Integer getMinutosEspera() {
        return minutosEspera;
    }

    public void setMinutosEspera(Integer minutosEspera) {
        Integer oldMinutosEspera = this.minutosEspera;
        this.minutosEspera = minutosEspera;
        changeSupport.firePropertyChange("minutosEspera", oldMinutosEspera, minutosEspera);
    }

    @XmlTransient
    public Collection<Deuda> getDeudaCollection() {
        return deudaCollection;
    }

    public void setDeudaCollection(Collection<Deuda> deudaCollection) {
        this.deudaCollection = deudaCollection;
    }

    public Usuarios getUsuarioidUsuario() {
        return usuarioidUsuario;
    }

    public void setUsuarioidUsuario(Usuarios usuarioidUsuario) {
        Usuarios oldUsuarioidUsuario = this.usuarioidUsuario;
        this.usuarioidUsuario = usuarioidUsuario;
        changeSupport.firePropertyChange("usuarioidUsuario", oldUsuarioidUsuario, usuarioidUsuario);
    }

    public Mesa getMesaidMesa() {
        return mesaidMesa;
    }

    public void setMesaidMesa(Mesa mesaidMesa) {
        Mesa oldMesaidMesa = this.mesaidMesa;
        this.mesaidMesa = mesaidMesa;
        changeSupport.firePropertyChange("mesaidMesa", oldMesaidMesa, mesaidMesa);
    }

    @XmlTransient
    public Collection<Detalleorden> getDetalleordenCollection() {
        return detalleordenCollection;
    }

    public void setDetalleordenCollection(Collection<Detalleorden> detalleordenCollection) {
        this.detalleordenCollection = detalleordenCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOrden != null ? idOrden.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orden)) {
            return false;
        }
        Orden other = (Orden) object;
        if ((this.idOrden == null && other.idOrden != null) || (this.idOrden != null && !this.idOrden.equals(other.idOrden))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidad.Orden[ idOrden=" + idOrden + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

    
}
